﻿Imports System
Imports System.Collections.Generic
Imports System.Text

Imports dewitcher.IO.FileSystem
Imports Cosmos.Core.INTs

Namespace CosmosKernel2

	Public Class Kernel
		Inherits Cosmos.System.Kernel

		Public VirtualFileSystem As New VirtualFileSystem

		Sub EscribirError()
			Console.ForegroundColor = ConsoleColor.Red
			Console.Write("ERROR")
			Console.ForegroundColor = ConsoleColor.White
		End Sub
		Sub EscribirOK()
			Console.ForegroundColor = ConsoleColor.Green
			Console.Write("OK")
			Console.ForegroundColor = ConsoleColor.White
		End Sub

		Sub cero(ByRef context As IRQContext)
			Console.WriteLine("ERROR!!!")
		End Sub

		Protected Overrides Sub BeforeRun()
			Console.ForegroundColor = ConsoleColor.White
			Console.WriteLine("Iniciando Mee OS...")
			Console.WriteLine()

			GruntyOS.CurrentUser.Privilages = 0	'0: root, 1: limitado
			GruntyOS.CurrentUser.Username = "admin"

			Console.Write("ACPI... ")

			If dewitcher.Core.ACPI.Init() Then
				EscribirOK()
			Else
				EscribirError()
			End If

			Console.WriteLine()

			Console.Write("IDT... ")

			'dewitcher.Core.IDT.Remap()

			Cosmos.Core.INTs.SetIrqHandler(0, Nothing)
			EscribirOK()
			Console.WriteLine()
		End Sub

		Protected Overrides Sub Run()
			Dim comando As String
			'Dim a As System.Collections.Generic.List(Of Char)
			'a = New System.Collections.Generic.List(Of Char)
			'a.Add(CChar("a"))
			'Console.CursorVisible = False

			Dim i As Integer = 0

			Console.Write(5 / i)
			Console.Write("> ")
			comando = Console.ReadLine()


			'Cosmos.Core()
			'Cosmos.Hardware()
			'Cosmos.Hardware2()
			'Cosmos.Kernel()
			'Cosmos.Sys()
			'Cosmos.System()

			'Console.ReadKey()
			dewitcher.Core.ACPI.Shutdown()

			'Console.Write()

			'Select Case comando
			'	Case "apagar"
			'		Console.WriteLine("Apagando...")


			'	Case Else
			'		Console.WriteLine("El comando especificado no existe.")
			'End Select

			'Cosmos.System.Global.Dbg.
			'Dbg.Send("prueba de debug")

		End Sub

	End Class

End Namespace